package javamusic.Servlet.Evento;

import java.io.IOException;

import javamusic.excepcion.DAOExcepcion;
import javamusic.negocio.GestionEvento;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ServletEventoModificar
 */
@WebServlet("/ServletEventoModificar")
public class ServletEventoModificar extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public ServletEventoModificar() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
				
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
				
		// TODO Auto-generated method stub
		
		String idevento1 = request.getParameter("idevento");
		int idevento = Integer.parseInt(idevento1);
		String nombre = request.getParameter("nombre");
		String fecha = request.getParameter("fecha");
		String capacidad1 = request.getParameter("capacidad");
		int capacidad = Integer.parseInt(capacidad1);
		String descripcion = request.getParameter("descripcion");
		String elog1 = request.getParameter("elog");
		int elog = Integer.parseInt(elog1);
		
		
		
		try {
			GestionEvento negocio = new GestionEvento();
			negocio.actualizar(idevento, nombre, fecha, capacidad, descripcion, elog);
		
			response.sendRedirect(request.getContextPath()	+ "/ServletEventoBuscar");
		} catch (DAOExcepcion e) {
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
		
	}

}